<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template>
    <div v-loading="loading">
      <el-form label-width="120px">

        <el-form-item label="腾讯地图KEY">
            <el-input v-model="qq_map_key" style="width: 300px" />
        </el-form-item>
        <el-form-item>
            <el-button type="primary" :disabled="loading" :loading="loading" size="small" icon="el-icon-check"
                @click="submitMapConfig">保存设置</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>

<script>
import { updateMapInfo } from "@/api/myconfig";
export default {
    name: 'sysinfo',
    props: {
        config: { type: Object, default: null },
    },
    watch: {
        config: {
            deep: true,
            handler(val, oldVal) {
                this.qq_map_key = val.qq_map_key;
            }
        }
    },
    data() {
        return {
            qq_map_key: '',
            loading: false,
        }
    },

    methods: {
        submitMapConfig: function () {
            if (!this.qq_map_key) {
                this.$message.error("请填写腾讯地图KEY");
                return;
            }
            this.loading = true
            updateMapInfo({
                qq_map_key: this.qq_map_key
            }).then((resp) => {
                this.loading = false
                if (resp.code != 0) {
                    return
                }
                this.$emit("updateConfig")
                this.$message.success("保存成功")
            })
        },
    },

}
</script>

<style></style>
